package com.sxj.springsourcecode.enity.postProcessor;

import com.sxj.springsourcecode.springframework.factory.BeanFactory;
import com.sxj.springsourcecode.springframework.factory.config.BeanDefinition;
import com.sxj.springsourcecode.springframework.factory.config.BeanFactoryPostProcessor;
import com.sxj.springsourcecode.springframework.factory.support.ConfigurableListableBeanFactory;

import java.util.Map;

/**
 * @ProjectName: spring-source-code
 * @Package: com.sxj.springsourcecode.enity.postProcessor
 * @ClassName: MyBeanFactoryPostProcessor
 * @Author: sxj
 * @Description:
 * @Date: 2024/2/22 0:12
 * @Version: 1.0.0
 */
public class MyBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
    @Override
    public void PostProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
        Map<String, BeanDefinition> definitionMap = beanFactory.getBeanDefinitionMap();
        for (Map.Entry<String, BeanDefinition> entry : definitionMap.entrySet()) {
            if (entry.getKey().equals("userService")){
                BeanDefinition beanDefinition = entry.getValue();
                beanDefinition.setPropertyValue("company","改为：网易");
                break;
            }
        }

    }
}
